package com.ziyia.a282;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.widget.DatePicker;
import android.widget.Toast;

public class MyDatePicker extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_date_picker);

        DatePicker datePicker = findViewById(R.id.datepicker);

        datePicker.setOnDateChangedListener(new DatePicker.OnDateChangedListener() {
            @Override
            public void onDateChanged(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                Toast.makeText(MyDatePicker.this, String.format("你选择的时间是 = %d 年 %d 月 %d 日",year, monthOfYear, dayOfMonth), Toast.LENGTH_SHORT).show();
            }
        });
    }
}